<ui:composition template="template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:define name="head">
		<script type="text/javascript" src="scheduling/scheduling.nocache.js" />
		<script type="text/javascript" src="wizard/wizard.nocache.js" />
		<c:if test="#{user.scheduleEditor}">
			<script type="text/javascript">
				//<![CDATA[
				var datacleaner = {
					onApiInitialized : function() {
						$(document).ready(function() {
							// check if wizard needs to start immediately
							var hashPartOfUri = window.location.hash;
							if (hashPartOfUri == "#startWizard") {
								datacleaner.startJobWizard();
								window.location.hash = "";
							}
						});
					}
				}

				function confirmUpload(fileType) {
					var input1 = $("#fileInput1").val();
					if(""=== input1 || input1.isEmpty){
						return false;
					}
					return true;
				}

				function showUploadJobForm(button) {
					$(button).replaceWith($("#UploadFileTemplateDiv"));
				}
				//]]>
			</script>
		</c:if>
	</ui:define>

	<ui:define name="content">
		<div id="SchedulingPage" class="container">
			<h:panelGroup rendered="#{param['job_upload'] == 'Success'}">
				<div class="alert alert-success">
					文件上传成功: #{param['job_filename'].replace("%2C", ", ")}
				</div>
			</h:panelGroup>
			<h:panelGroup rendered="#{param['job_upload'] != null and param['job_upload'] != 'Success'}">
				<div class="alert alert-success">文件上传成功。 </div>
			</h:panelGroup>

			<c:if test="#{user.scheduleEditor}">
				<div>
					<button class="btn btn-primary"
						onclick="datacleaner.startJobWizard();">
						<span class="glyphicon glyphicon-plus" aria-hidden="true" /> <span>新建任务</span>
					</button>
					<form action="repository/#{user.tenant}/jobs/multiple_upload"
						method="post" enctype="multipart/form-data" class="form-inline" style="display: inline;"
						id="uploadJobs">
						<button class="btn btn-default" onclick="showUploadJobForm(this)" type="button">
							<span class="glyphicon glyphicon-upload" aria-hidden="true" /> <span>上传任务</span>
						</button>
					</form>
				</div>

				<div class="spacer"></div>
			</c:if>

			<div id="RootPanelTarget"></div>
		</div>

		<div style="visibility: hidden; display: none">
			<div id="UploadFileTemplateDiv" style="display: inline-block;">
				<div class="input-group">
					<span class="input-group-btn">
						<span class="btn btn-primary btn-file"> 浏览 …
						<input type="file" name="files" multiple="multiple" />
					</span>
					</span>
					<input id="fileInput1" type="text" class="form-control" readonly="readonly" />
				</div>

				<button type="submit" class="btn btn-primary"
					onclick="return confirmUpload('job')">
					<span class="glyphicon glyphicon-upload" aria-hidden="true" /> <span>上传</span>
				</button>

			</div>
		</div>
	</ui:define>

</ui:composition>


